define(function(require, exports, module){

	require('jquery');
	require('utility');
	require('object');

	var Kinetic = require('kinetic');

	var GameHelper = require('./GameHelper'),
		GameUtil = GameHelper.GameUtil;

	var C = {
		w:640,
		h:960,

		isResizing : false
	};
	var page, stage;
	var lay1, lay2;

	var F = {
		init : function(){
			F.initVar();
			F.initView();
			F.initEvent();

			$('.loadingGame').remove();

			F.resize();
			stage.draw();
		},

		initVar : function(){
			page = $('.page');
			stage = new Kinetic.Stage({
				id : 'stage',
				width : C.w,
				height : C.h,
				container : 'js_main'
			});

			lay1 = new Kinetic.Layer({
				x:0,
				y:0
			});


			var rect = new Kinetic.Rect({
				fill : '#ffffff',
				x : 10,
				y : 10,
				width : 100,
				height : 100
			});
			lay1.add(rect);

			stage.add(lay1);
		},

		initView : function(){

		},

		initEvent : function(){
			$(window).on('resize', function(){
				C.isResizing = true;;
			});

			window.setInterval(function(){
				if(C.isResizing){
					C.isResizing = false;
					F.resize();
				}
			}, 50);
		},

		resize : function(){
			var h = $(window).height(),
				w = h*640/960;
			if(w<320) w = 320;
			stage.size({
				width : w,
				height : h
			});
			lay1.size({
				width : w,
				height : h
			})
		}
	};



	exports.init = F.init;
});